package Demo;

public class Demo02 {
    public static void main(String[] args) throws InterruptedException {
        Object locker = new Object();

        Thread t1 = new Thread( () -> {
            System.out.println("t1唤醒前");
            synchronized(locker) {
                try {
                    locker.wait();
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
            System.out.println("t1唤醒后");
        });

        Thread t2 = new Thread( () -> {
            System.out.println("t2唤醒前");
            synchronized(locker) {
                try {
                    locker.wait();
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
            System.out.println("t2唤醒后");
        });

        Thread t3 = new Thread( () -> {
            System.out.println("t3唤醒前");
            synchronized(locker) {
                try {
                    locker.wait();
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
            System.out.println("t3唤醒后");
        });

        t1.start();
        t2.start();
        t3.start();

        Thread.sleep(1);

        synchronized(locker) {
            locker.notifyAll();
        }



    }
}
